mini.parse();
var grid1 = mini.get("datagrid1");
//获取表格数据（列数据，表格数据）
// $.ajax({
//     url: "http://192.168.178.160:8080/bpm/classTable/findByTableId.do?id="+id,
//     type: "post",
//     dataType: "json",
//     data : {
//     },
//     traditional: true,
//     success: function(data) {
//         console.log(data);
//         grid1.set({
//             columns: [
//                 { type: "checkcolumn" },
//                 { field: "name", width: 120, headerAlign: "center", allowSort: true,
//                     header: "员工账号"},
//             ]
//         });
//         grid1.setData(data.data);
//     },
//     error : function(data){
//         alert('失败');
//     }
// });

grid1.set({
    columns: [
        { type: "checkcolumn" },
        { field: "test_table_code", width: 120, headerAlign: "center", allowSort: true,
            header: "员工账号"},
        { field: "code1", width: 120, headerAlign: "center", allowSort: true,
            header: "测试1"}
    ]
});

var data = [{test_table_code:"账号1",code1:"1111"},{test_table_code:"账号2",code1:"2222"},{test_table_code:"",code1:"3333"},{test_table_code:"",code1:"4444"}];
grid1.setData(data);
console.log(grid1);

function SetData(data) {
    data = mini.clone(data);
    // console.log(data.reference[0].createTables);
    var maps = '';
    for(var i=0;i< data.reference[0].createTables.length;i++) {
        maps+= data.reference[0].createTables[i].field + ',';
    }
    maps=maps.substring(0,maps.length-1);//截取掉最后一位
    console.log(maps);

    $.ajax({
        url: ajaxUrl + "/Base/findAll.do",
        type: "post",
        dataType: "json",
        data : {
            tableName: data.reference[0].tableClassName,
            maps: maps
        },
        success: function (data) {
            console.log(data);
        },
        error:function(data){
            alert('请求失败');
        }
    });
}

//确定按钮之前
function onTableOk() {
    var grid = mini.get("datagrid1");
    var gridSelected = grid.getSelecteds();
    // console.log(gridSelected);
    return gridSelected; //返回选中的数据给父组件
}

//确定按钮
function onOk(e) {
    CloseWindow("ok");
}
//取消按钮
function onCancel(e) {
    CloseWindow("cancel");
}

function CloseWindow(action) {

    if (window.CloseOwnerWindow)
        return window.CloseOwnerWindow(action);
    else
        window.close();
}
